package com.example.demo.util;

import java.time.LocalDate;
import java.util.Date;

/**
 * Copyright © 合生活. All rights reserved.
 *
 * @Title: DateUtils
 * @Prject: ttc
 * @Package: com.feejson.ttc.util
 * @Description: 积累的时间日期工具类
 * @author: feejson
 * @date: 2019-01-25 15:29
 * @version: V1.0
 */
public class DateUtils {

    /**
     * 获取次年年份第一天日期  yyyy-MM-dd
     * @return
     */
    public static String getTheFirstDayOfTheFollowingYear(){
        LocalDate local = LocalDate.now();
        int year = local.minusYears(-1).getYear();
        String value = new StringBuilder(year).append("-01-01").toString();
        return value;
    }

    /**
     * 获取当年年最后一天日期  yyyy-MM-dd
     * @return
     */
    public static String getTheLastDayOfTheYear(){
        LocalDate local = LocalDate.now();
        int year = local.getYear();
        String value = new StringBuilder(year).append("-12-31").toString();
        return value;
    }

    /**
     * 判断年份是否大于当前年费
     */
    public static boolean judgingYearBigThanNowYear(String dateStr){
        LocalDate nowDate = LocalDate.now();
        LocalDate paramDate = LocalDate.parse(dateStr);
        int nowYear = nowDate.getYear();
        int paramYear = paramDate.getYear();
        if (paramYear > nowYear){
            return true;
        }
        return  false;
    }

    public static void main(String[] args) {
        System.out.println(judgingYearBigThanNowYear("2020-01-02"));

    }

}
